/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>

#include "sle_host_server.h"
#include "sle_host_callback_stub.h"

class SleHostServerTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp() override;
    void TearDown() override;

};
void SleHostServerTest::SetUp(){}
void SleHostServerTest::TearDown(){}
void SleHostServerTest::SetUpTestCase(){}
void SleHostServerTest::TearDownTestCase(){}

namespace OHOS {
namespace NearLink {
namespace SleStandard {

class SleHostCallbackStubMock : public SleHostCallbackStub {
    public:
        void OnSleStateChange(int32_t state)
        {

        }
        void OnFlowMonitorEvent(float flow)
        {

        }

};


HWTEST_F(SleHostServerTest, OnStart_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();
    hostServer->OnStart();
}


// HWTEST_F(SleHostServerTest, Init_001, testing::ext::TestSize.Level0)
// {
//     sptr<SleHostServer> hostServer = SleHostServer::GetInstance();
//     SleErrorCode result = hostServer->Init();
//     EXPECT_EQ(result, SLE_NO_ERROR);
// }


HWTEST_F(SleHostServerTest, RegisterHostCallback_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    sptr<SleHostCallbackStubMock> callback = new SleHostCallbackStubMock();
    SleErrorCode result = hostServer->RegisterHostCallback(callback);
    EXPECT_EQ(result, SLE_NO_ERROR);
}


HWTEST_F(SleHostServerTest, UnregisterHostCallback_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    sptr<SleHostCallbackStubMock> callback = new SleHostCallbackStubMock();
    SleErrorCode result = hostServer->UnregisterHostCallback(callback);
    EXPECT_EQ(result, SLE_ERR_FAILED);
}


// HWTEST_F(SleHostServerTest, EnableSle_001, testing::ext::TestSize.Level0)
// {
//     sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

//     sptr<SleHostCallbackStubMock> callback = new SleHostCallbackStubMock();
//     SleErrorCode result = hostServer->RegisterHostCallback(callback);
//     result = hostServer->EnableSle();
//     EXPECT_EQ(result, SLE_NO_ERROR);
// }


HWTEST_F(SleHostServerTest, DisableSle_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    SleErrorCode result = hostServer->DisableSle();
    EXPECT_EQ(result, SLE_ERR_DISABLE_SUCCESS_WHEN_DISABLED);
}


HWTEST_F(SleHostServerTest, GetSleState_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    int32_t state;
    SleErrorCode result = hostServer->GetSleState( state);
    EXPECT_EQ(result, SLE_NO_ERROR);
}


HWTEST_F(SleHostServerTest, SetHostName_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    std::string name = "test";
    SleErrorCode result = hostServer->SetHostName(name);
    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}

HWTEST_F(SleHostServerTest, GetHostName_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    std::string name;
    SleErrorCode result = hostServer->GetHostName(name);
    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}

HWTEST_F(SleHostServerTest, StartFlowMonitor_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    SleErrorCode result = hostServer->StartFlowMonitor();
    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}

HWTEST_F(SleHostServerTest, StopFlowMonitor_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    SleErrorCode result = hostServer->StopFlowMonitor();
    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}


HWTEST_F(SleHostServerTest, GetHostDefaultConnectConfig_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    SleConnectConfig hostConnParam;
    SleErrorCode result = hostServer->GetHostDefaultConnectConfig(hostConnParam);
    EXPECT_EQ(result, SLE_ERR_CHECKOUT_FAILED);
}

HWTEST_F(SleHostServerTest, GetSleServerRemote_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();

    std::string name;
    sptr<OHOS::IRemoteObject> result = hostServer->GetSleServerRemote(name);
    EXPECT_FALSE(result );
}



HWTEST_F(SleHostServerTest, OnStop_001, testing::ext::TestSize.Level0)
{
    sptr<SleHostServer> hostServer = SleHostServer::GetInstance();
    hostServer->OnStop();
}



}}}